let uu = document.querySelector('.uu')
let xie = document.querySelector('.xie')
let foot = document.querySelector('.footer1>div>b:nth-of-type(3)')
let span = document.querySelector('span')
function getQueryString() {
    let url = location.href
    console.log(url)
    let reg = /(?<=\?).*/
    let r = url.match(reg)
    console.log(r)
    let rm = r[0]
    console.log(rm)
    fetch('http://chst.vip:1234/api/getbrandproductlist?' + rm)
        .then(body => body.json())
        .then(res => {
            console.log(res)
            let _this = res.result
            console.log(_this[0])
            let domStr = ''
            _this.forEach(item => {
                console.log(item)
                domStr += `<li brandtitleid=${item.brandTitleId}>
            <a href="./../html/pinpaixiangqing.html?name=${item.brandName}">
            ${item.productImg}
            <p>${item.productName}</p>
            <p>${item.productPrice}</p>
            <b>${item.productCom}</b>
            </a>
            </li>`
                uu.innerHTML = domStr
            })
        })
}
getQueryString()

function mianbao() {
    let title = location.href
    title = decodeURI(title)
    let reg = /(?<=\?).*/
    let tit = title.match(reg)
    let t = tit[0]
    let i = t.split('&')
    let obj = {};
    i.forEach(item => {
        let itemArr = item.split('=');
        obj[itemArr[0]] = itemArr[1]
    })
    console.log(obj['name'])
    let domStr = ''
    domStr = `<b>首页</b>>
                <b class="xie1">全部分类</b>>
                <b>${obj['name']}</b>
                `
    xie.innerHTML = domStr
}
mianbao()
uu.onclick = function (e) {
    if (e.target.localName == 'li') {
        let _this = e.target
        console.log(_this)
        let id = _this.getAttribute('brandtitleid')
        console.log(id);
        id = Number(id)
    }
}

xie.onclick = function () {
    location.href = "../index.html"
}
$('.xie').on('click', '.xie1', function () {

    location.href = "../html/pinpaidaquan.html"
})

span.onclick = function () {
    location.href = "../html/pinpaidaquan.html"
}
foot.onclick = function () {
    location.href = "../html/pinpaidaquan.html"
}